#include <iostream>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

class Solution {
public:
    int cutRope(int number) {
        if(number==2){
            return 1;
        }else if(number==3){
            return 2;
        }
        if(number%3==0){
            return (int)pow(3,number/3);
        }else if(number%3==1){
            return 4*(int)pow(3,number/3-1);
        }else if(number%3==2){
            return 2*(int)pow(3,number/3);
        }
    }
};
int main(){

    int n;
    Solution s;
    while(cin >> n){
        cout << s.cutRope(n)<<endl;
    }


    return 0;
}